package com.xhu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xhu.mapper.SaleAnalysisMapper;
import com.xhu.pojo.SaleAnalysis;
import com.xhu.service.SaleAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SaleAnalysisServiceImpl extends ServiceImpl<SaleAnalysisMapper, SaleAnalysis> implements SaleAnalysisService {

    @Autowired
    SaleAnalysisMapper mapper;


    @Override
    public IPage<SaleAnalysis> getAllByPage(int current, int size) {

        return mapper.selectPage(new Page<>(current, size), null);

    }

    @Override
    public IPage<SaleAnalysis> getAllByMonth(int current, int size, String month) {
        LambdaQueryWrapper<SaleAnalysis> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(SaleAnalysis::getMonth, month);

        return mapper.selectPage(new Page<>(current, size), wrapper);
    }

}
